
package com.lzx.iteam.contactssearch;

import android.widget.ListView;
import com.lzx.iteam.CloudDialerActivity;
import com.lzx.iteam.contactssearch.ContactsSearchList.SearchStatus;
import com.lzx.iteam.util.Constants;

public class ResultListManager {
    private static final String TAG = "ResultListManager";

    ContactsSearchList mResultList;
    ContactsSearchList mLastList;
    
    CloudDialerActivity mActivity;
    
    int mFlag;
    
    public int getListFlag() {
        return mFlag;
    }
    
    public void setListFlag(int flag) {
        mFlag = flag;
    }
    
    public void cancelSearch() {
//        mCallsList.mStatus = SearchStatus.ENUM_SEARCH_NONE;
        mResultList.mStatus = SearchStatus.ENUM_SEARCH_NONE;    
    }

    public void onRefresh(String keyword, boolean ifShowPeopleNoPhone) {
        if (mFlag == Constants.SHOW_CONTACT_INFO || mFlag == Constants.SHOW_GROUP_INFO) {
            freshResultList(keyword, ifShowPeopleNoPhone);
        }
    }
    
    public ResultListManager(CloudDialerActivity mActivity, ListView mList, int flag) {
//        mCallsList = new CallLogList(mActivity, mList);
        mResultList = new ResultList(mActivity, mList);
        mFlag = flag;
        this.mActivity = mActivity;
    }
    

    public void freshResultList(String keyword, boolean ifShowPeopleNoPhone) {
        //mResultList.onResume();
        mResultList.refresh(keyword, ifShowPeopleNoPhone);
    }
    
    public void freshGroupResultList(String groupId,String keyword, boolean ifShowPeopleNoPhone) {
        //mResultList.onResume();
        mResultList.refreshGroup( groupId,keyword, ifShowPeopleNoPhone);
    }
    
    
    public void onDestroy() {
        mLastList = null;
//        mCallsList.onDestroy();
//        mCallsList = null;
        mResultList.onDestroy();
        mResultList = null;
    }

    public ResultList getResultList() {
        return (ResultList)mResultList;
    }
    
}
